package notify.xgx.com.notifydemo;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity2 extends RootActivity implements INotifycallBack {
    Button btn_1, btn_2, btn_3;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_two);
        MobileApplication.addNotifynotifycode(this.getClass(), NotifyInfo.NOTIFYCODE.FINISH);
        MobileApplication.addNotifyCallBackIntoPool(this.getClass(), this);
        init();
    }


    private void init() {
        btn_1 = (Button) findViewById(R.id.btn1);
        btn_2 = (Button) findViewById(R.id.btn2);
        btn_3 = (Button) findViewById(R.id.btn3);

        //带延时的
        btn_1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MobileApplication.notifyCallBackDelay(MainActivity.class, NotifyInfo.NOTIFYCODE.FINISH, 3000, new INotifycallBackResp() {
                    @Override
                    public void onResp(NotifyInfo.NOTIFYCODE notifycode, Object obj) {
                        PalLog.printE("MainActivity2 onResp  " + obj);
                    }
                }, "");
            }
        });

        //指定的
        btn_2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MobileApplication.notifyCallBack(this.getClass(), NotifyInfo.NOTIFYCODE.FINISH,"");
            }
        });

        //广播的
        btn_3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MobileApplication.notifyCallBack(NotifyInfo.NOTIFYCODE.FINISH,"");
            }
        });



    }

    @Override
    public Object onNotify(NotifyInfo.NOTIFYCODE notifycode, Object... objs) {
        if (notifycode == NotifyInfo.NOTIFYCODE.FINISH) {
            PalLog.printE(" activity2 says:  some one call me!!!! notifyCode is  " + notifycode);
            return "my name is activity2";
        }
        return "";
    }
}
